//
//  MPBModel+MerageFunc.h
//  MiaoPai
//
//  Created by jiaxuzhou on 2017/8/14.
//  Copyright © 2017年 Jeakin. All rights reserved.
//

#import "MPBModel.h"

@interface MPBModel (MerageFunc)

- (void)mergeValuesForKeysFromModel:(MPBModel *)model;

- (void)mergeValueForKey:(NSString *)key fromModel:(MPBModel *)model;

SEL MPTSelectorWithKeyPattern(NSString *key, const char *suffix) __attribute__((pure, nonnull(1, 2)));

// Creates a selector from a key and a constant prefix and suffix.
//
// prefix - A string to prepend to the key as part of the selector.
// key    - The key to insert into the generated selector. This key should be in
//          its natural case, and will have its first letter capitalized when
//          inserted.
// suffix - A string to append to the key as part of the selector.
//
// Returns a selector, or NULL if the input strings cannot form a valid
// selector.
SEL MPTSelectorWithCapitalizedKeyPattern(const char *prefix, NSString *key, const char *suffix) __attribute__((pure, nonnull(1, 2, 3)));



typedef void (^mpt_ext_cleanupBlock_t)();

void mpt_ext_executeCleanupBlock (__strong mpt_ext_cleanupBlock_t *block);

#define mpt_metamacro_concat_(A, B) A ## B
#define mpt_metamacro_concat(A, B) \
mpt_metamacro_concat_(A, B)

#if DEBUG
#define mpt_ext_keywordify autoreleasepool {}
#else
#define mpt_ext_keywordify try {} @catch (...) {}
#endif


#define MPTonExit \
mpt_ext_keywordify \
__strong mpt_ext_cleanupBlock_t mpt_metamacro_concat(ext_exitBlock_, __LINE__) __attribute__((cleanup(mpt_ext_executeCleanupBlock), unused)) = ^


@end
